<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <#assign base=request.contextPath  />
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title></title>
    <link rel="stylesheet" href="../frame/layui/css/layui.css">
    <link rel="stylesheet" href="../frame/static/css/style.css">
    <link rel="icon" href="../frame/static/image/code.png">
    <script type="text/javascript" src="../frame/layui/layui.all.js"></script>
    <script type="text/javascript" src="${base}/js/zhang.js"></script>
<script type="text/javascript" src="../frame/layui/layui.all.js"></script>
    <script src="${base}/js/jquery-1.8.3.min.js"></script>

</head>

<body class="body">
<div class="ziyemianbiju">
    <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
        <div class="my-btn-box">
            <span  id="layerDemo">
                <span class="layui-form-label">企业成员</span>
                <div class="layui-input-inline">
                    <input type="text" autocomplete="off" placeholder="手机号" class="layui-input isNull isNum" id="phone" style="height: 31px;">
                </div>

                	<button class="layui-btn layui-btn-normal  layui-btn-sm"   id="selectphone" >查询</button>
            </span>
            <table class="layui-hide" id="test" lay-filter="test"></table>
            <script type="text/html" id="barDemo">
                <betton  class="layui-btn layui-btn-normal layui-btn-xs " lay-event="edit"  >审核</betton>

            </script>
        </div>
    </div>
    <script type="text/javascript">
        layui.use(['layer','form','table'], function(){
            var form = layui.form;
            var table = layui.table;
            var layer = layui.layer;
            var $ = layui.jquery;
            table.render({
                even: true,//开启隔行背景
                size: 'sm',//小尺寸的表格
                elem: '#test',
                toolbar: '#toolbarDemo',
                url: '${base}/company/select',
                title: '用户数据表',
                cols: [[
                    {type: 'checkbox',width:40}
                    ,{field:'ptname', title: '已认证企业',align:'center'}
                    ,{field:'callName', title: '联系人姓名',align:'center', templet: '#phoneTpl'}
                    ,{field:'callPhone', title: '联系人手机号',align: 'center'}
                    ,{field:'relactionUserInfo', title: '法人信息',align:'center'}
                    ,{field:'flag', title: '是否通过',align:'center',
                        templet:function(val){
                            var flag=val.flag;
                            if(flag==2){
                                return "不通过"
                            }else{
                                return"通过"
                            }
                        }}
                    ,{field:'falseInfo', title: '未通过原因', align:'center'}
                    ,{field:'eczxxxxema', title: '操作', align:'center', toolbar: '#barDemo'}
                ]]
                ,id: 'testReload'
                ,height:480
                ,page: {
                    layout: ['limit', 'count', 'prev', 'page', 'next', 'skip']
                    ,theme: '#9AC747'
                    ,limit: 10
                }
            });





            //页面传参
           table.on('tool(test)', function(obj){
                var layEvent = obj.event;
                if(layEvent=="edit"){
                        var data = obj.data;
                    //示范一个公告层
                    layer.open({
                        type: 2,
                        title: '编辑',
                        shadeClose:false ,
                        offset: 't',
                        area:['100%','100%'],
                        content: '${base}/company/check.html?url='
                        +data.url,
                        success: function (layero, index) {
                            //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                            var iframeWin = window[layero.find('iframe')[0]['name']];

                            iframeWin.$("#ptname").val(data.ptname);
                            iframeWin.$("#callName").val(data.callName);
                            iframeWin.$("#callPhone").val(data.callPhone);
                            iframeWin.$("#relactionUserInfo").val(data.relactionUserInfo);
                            iframeWin.$("#falseInfo").val(data.falseInfo);
                            iframeWin.$("#id").val(data.id);
                            //渲染一下form表单
                            iframeWin.layui.form.render('select');
                            iframeWin.layui.form.render();
                        }
                    });
                }

            });






        });

        //键盘事件
        $("body").bind("keydown",function(e){
            // 兼容FF和IE和Opera
            var theEvent = e || window.event;
            var code=theEvent.keyCode || theEvent.which || theEvent.charCode;
            if (code==13) {
                //回车执行查询
                $("#selectphone").click();
            }
        });




//根据手机查询
        $('#selectphone').on('click',function () {
            var phone=$("#phone").val();
            if(!isNum()){
                alert("请输入数字")
                return;
            }
            // if(!isNull()){
            //     alert("请输入手机号")
            //     return;
            // }
            if (phone==null || phone==''){
                var table = layui.table;
                table.reload(
                        'testReload', {
                            url: '${base}/company/select',
                        });
            }else {
                var table = layui.table;
                table.reload(
                        'testReload', {
                            url: '${base}/company/selectphone',
                            where: {phone: phone} //设定异步数据接口的额外参数
                        });

            }



        })






    </script>
</body>

</html>